#include<iostream>
#include<boost/graph/adjacency_list.hpp>
#include<boost/graph/graphviz.hpp>
#include<string>
using namespace std;
using namespace boost;


struct vertexData
{
	string vertex_name;
};

struct edgeData
{
	string edge_name;
	double distances;
};


void create_graph(){
	typedef adjacency_list<listS, vecS, directedS, vertexData, edgeData> Graph2;
	Graph2 myGraph;
	const char* name = "ABCDE";
	vertexData v[] = {{"A"}, {"B"}, {"C"}, {"D"}, {"E"}};
	//auto v = add_vertex(myGraph);
	//auto vv[5] = {};
	//auto vv = NULL;

	graph_traits<Graph2>::vertex_descriptor vv[5];


	for(int i = 0; i < 5; i++){
		vv[i] = add_vertex(v[i], myGraph);
	}
	cout << get(&vertexData::vertex_name, myGraph)[vv[0]] << endl;
	// auto vv = add_vertex(v[4], myGraph);
	// get(&vertexData::vertex_name, myGraph)[vv] = "B";
	// cout << get(&vertexData::vertex_name, myGraph)[vv] << endl;
	// auto v = add_vertex(v1, myGraph);
	// //typedef property_map<Graph2, vertexData>::type vertex_map = get(vertexData(), Graph2);
	// put(&vertexData::vertex_name, v, "B");
	// cout << get(&vertexData::vertex_name, myGraph)[v] <<endl;
	edgeData e[] = {{"AB", 10}, {"AC", 15}, {"BD", 15}, {"CE", 10}};
	add_edge(vv[0], vv[1], e[0], myGraph);
	add_edge(vv[0], vv[2], e[1], myGraph);
	add_edge(vv[1], vv[3], e[2], myGraph);
	add_edge(vv[2], vv[4], e[3], myGraph);

	//write_graphviz(std::cout, myGraph, make_label_writer(name));
	write_graphviz(std::cout, myGraph,
    boost::make_label_writer(boost::get(&vertexData::vertex_name, myGraph)),
    boost::make_label_writer(boost::get(&edgeData::distances, myGraph))
    //boost::make_label_writer(boost::get(&edgeData::edge_name, myGraph))   //只能出现一个
    );

    cout << num_vertices(myGraph) <<endl;
    cout << num_edges(myGraph) << endl;
}


int main(){
	create_graph();
	// typedef adjacency_list<listS, vecS, directedS> Graph;

	// enum {A, B, C, D, E, N};
	// const char* name  = "ABCDE";

	// const int num_vertexs = N;
	// Graph g(num_vertexs);

	// typedef pair<int, int> Edge;
	// Edge edge_array[] = {
	// 	Edge(A, C), Edge(A, B), 
	// 	Edge(B, D), Edge(C, E)
	// };

	// const int num_edges = sizeof(edge_array) / sizeof(edge_array[0]);

	// for(int i = 0; i < num_edges; i++){
	// 	add_edge(edge_array[i].first, edge_array[i].second, g);
	// }

	// write_graphviz(std::cout, g, make_label_writer(name));

	return 0;
}
